var express = require('express');
var app = express.createServer();
app.configure(function(){
    app.use(express.methodOverride());
    app.use(express.bodyParser());
    app.use(app.router);
});
app.configure('development', function(){
    //app.use(express.static(__dirname + '/public'));
    app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});

//var mongodb = require('mongodb');  
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost:27017/test');
var Schema = mongoose.Schema;
var foo = new Schema({
    a     : String
});
var myModel = mongoose.model('foo',foo,'foo');
app.get('/', function(req, res){
  //res.send('hello world');
 var str='';
  myModel.find({}, function (err, docs) {
    docs.forEach(function(elem, index, array) {
		 console.log(elem.a);
		 str+=elem.a;
	});
	console.log(str);
	res.send(req.headers);
   });
	
});


console.log("server started!");
app.listen(3000);